#include<iostream>
#include<string>
using namespace std;
int n;
int st[30];
string s1, s2;
int main()
{
	cin >> n;
	cin >> s1 >> s2;
	int sum1 = 0, sum2 = 0;
	int cnt = 0;
	bool flag = 0;
	for (int i = 0; i < s2.size(); i++) {
		if (s2[i] != s1[i]) {
			sum1 += s1[i] - 'a' + 1;
			sum2 += s2[i] - 'a' + 1;
			cnt++;
		}
		int k = s1[i] - 'a' + 1;
		st[k]++;
		if (st[k] >= 2) {
			flag = 1;
		}
	}
	if ((!cnt && flag) || (cnt == 2 && sum1 == sum2)) {
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
	return 0;
}